////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  camxoisdriver.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "camxoisdriver.h"
#include "parametersetmanager.h"

CAMX_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OISDriverDataClass::OISDriverDataClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, 0, 0, 0, 0)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(slaveInfo);
    PARAMETER_INITIALIZE(opcode);
    PARAMETER_INITIALIZE(oisinitSettings);
    PARAMETER_INITIALIZE(enableOisSettings);
    PARAMETER_INITIALIZE(disableOisSettings);
    PARAMETER_INITIALIZE(enterDownloadModeSettingsExists);
    PARAMETER_INITIALIZE(enterDownloadModeSettingsID);
    PARAMETER_INITIALIZE(enterDownloadModeSettings);
    PARAMETER_INITIALIZE(movieModeSettingsExists);
    PARAMETER_INITIALIZE(movieModeSettingsID);
    PARAMETER_INITIALIZE(movieModeSettings);
    PARAMETER_INITIALIZE(stillModeSettingsExists);
    PARAMETER_INITIALIZE(stillModeSettingsID);
    PARAMETER_INITIALIZE(stillModeSettings);
    PARAMETER_INITIALIZE(centeringOnSettingsExists);
    PARAMETER_INITIALIZE(centeringOnSettingsID);
    PARAMETER_INITIALIZE(centeringOnSettings);
    PARAMETER_INITIALIZE(centeringOffSettingsExists);
    PARAMETER_INITIALIZE(centeringOffSettingsID);
    PARAMETER_INITIALIZE(centeringOffSettings);
    PARAMETER_INITIALIZE(pantiltOnSettingsExists);
    PARAMETER_INITIALIZE(pantiltOnSettingsID);
    PARAMETER_INITIALIZE(pantiltOnSettings);
    PARAMETER_INITIALIZE(sceneOisSettingsExists);
    PARAMETER_INITIALIZE(sceneOisSettingsID);
    PARAMETER_INITIALIZE(sceneOisSettings);
    PARAMETER_INITIALIZE(sceneFilterOnSettingsExists);
    PARAMETER_INITIALIZE(sceneFilterOnSettingsID);
    PARAMETER_INITIALIZE(sceneFilterOnSettings);
    PARAMETER_INITIALIZE(sceneFilterOffSettingsExists);
    PARAMETER_INITIALIZE(sceneFilterOffSettingsID);
    PARAMETER_INITIALIZE(sceneFilterOffSettings);
    PARAMETER_INITIALIZE(sceneRangeOnSettingsExists);
    PARAMETER_INITIALIZE(sceneRangeOnSettingsID);
    PARAMETER_INITIALIZE(sceneRangeOnSettings);
    PARAMETER_INITIALIZE(sceneRangeOffSettingsExists);
    PARAMETER_INITIALIZE(sceneRangeOffSettingsID);
    PARAMETER_INITIALIZE(sceneRangeOffSettings);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OISDriverDataClass::OISDriverDataClass(
    const CHAR* name,
    UINT32 modeId,
    UINT16 mode,
    UINT16 subMode,
    UINT32 group)
    : ParameterModule(name, MAJOR, MINOR, PATCH, modeId, mode, subMode, group)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(slaveInfo);
    PARAMETER_INITIALIZE(opcode);
    PARAMETER_INITIALIZE(oisinitSettings);
    PARAMETER_INITIALIZE(enableOisSettings);
    PARAMETER_INITIALIZE(disableOisSettings);
    PARAMETER_INITIALIZE(enterDownloadModeSettings);
    PARAMETER_INITIALIZE(movieModeSettings);
    PARAMETER_INITIALIZE(stillModeSettings);
    PARAMETER_INITIALIZE(centeringOnSettings);
    PARAMETER_INITIALIZE(centeringOffSettings);
    PARAMETER_INITIALIZE(pantiltOnSettings);
    PARAMETER_INITIALIZE(sceneOisSettings);
    PARAMETER_INITIALIZE(sceneFilterOnSettings);
    PARAMETER_INITIALIZE(sceneFilterOffSettings);
    PARAMETER_INITIALIZE(sceneRangeOnSettings);
    PARAMETER_INITIALIZE(sceneRangeOffSettings);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OISDriverDataClass::~OISDriverDataClass()
{
    UnloadOISDriverData(this);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* OISDriverDataClass::GetName(
    const CHAR* type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ParameterFileSymbolTableEntry::GetType(temp, "OISDriver")) == 0)
    {
        name = "OISDriver";
    }
    return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load OISSlaveInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL OISDriverDataClass::LoadOISSlaveInfo(
    ParameterFileSymbolTableEntry* entry,
    OISSlaveInfo* structure)
{
    BOOL result = TRUE;

    // Reading structure->OISName from the symbol table
    {
        UINT32 OISNameCount = 0;
        result = result && entry->ReadUInt32(&OISNameCount);
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        structure->OISName = NULL;
        if (result)
        {
            pointerEntry1->ReadString(&structure->OISName, OISNameCount);
        }
    }
    result = result && entry->ReadUInt16(&structure->slaveAddress);
    structure->i2cFrequencyMode = (I2CFrequencyMode)entry->ReadEnum(&result);
    result = result && entry->ReadUInt16(&structure->fwflag);
    result = result && entry->ReadUInt16(&structure->oiscalib);
    result = result && camxsensorcommonClass::LoadPowerSequenceInfo(entry, &structure->powerUpSequence);
    result = result && camxsensorcommonClass::LoadPowerSequenceInfo(entry, &structure->powerDownSequence);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load OISopcode
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL OISDriverDataClass::LoadOISopcode(
    ParameterFileSymbolTableEntry* entry,
    OISopcode* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->prog);
    result = result && entry->ReadUInt32(&structure->coeff);
    result = result && entry->ReadUInt32(&structure->pheripheral);
    result = result && entry->ReadUInt32(&structure->memory);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load OISDriverData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL OISDriverDataClass::LoadOISDriverData(
    ParameterFileSymbolTableEntry* entry,
    OISDriverData* structure)
{
    BOOL result = TRUE;
    result = result && Loadmodule_versionStruct(entry, &structure->module_version);
    result = result && LoadOISSlaveInfo(entry, &structure->slaveInfo);
    result = result && LoadOISopcode(entry, &structure->opcode);
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->oisinitSettings);
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->enableOisSettings);
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->disableOisSettings);

    // Reading structure->enterDownloadModeSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->enterDownloadModeSettingsExists);
        structure->enterDownloadModeSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->enterDownloadModeSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->enterDownloadModeSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->enterDownloadModeSettings);
        }
    }

    // Reading structure->movieModeSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->movieModeSettingsExists);
        structure->movieModeSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->movieModeSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->movieModeSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->movieModeSettings);
        }
    }

    // Reading structure->stillModeSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->stillModeSettingsExists);
        structure->stillModeSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->stillModeSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->stillModeSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->stillModeSettings);
        }
    }

    // Reading structure->centeringOnSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->centeringOnSettingsExists);
        structure->centeringOnSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->centeringOnSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->centeringOnSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->centeringOnSettings);
        }
    }

    // Reading structure->centeringOffSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->centeringOffSettingsExists);
        structure->centeringOffSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->centeringOffSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->centeringOffSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->centeringOffSettings);
        }
    }

    // Reading structure->pantiltOnSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->pantiltOnSettingsExists);
        structure->pantiltOnSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->pantiltOnSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->pantiltOnSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->pantiltOnSettings);
        }
    }

    // Reading structure->sceneOisSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->sceneOisSettingsExists);
        structure->sceneOisSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->sceneOisSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->sceneOisSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->sceneOisSettings);
        }
    }

    // Reading structure->sceneFilterOnSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->sceneFilterOnSettingsExists);
        structure->sceneFilterOnSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->sceneFilterOnSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->sceneFilterOnSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->sceneFilterOnSettings);
        }
    }

    // Reading structure->sceneFilterOffSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->sceneFilterOffSettingsExists);
        structure->sceneFilterOffSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->sceneFilterOffSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->sceneFilterOffSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->sceneFilterOffSettings);
        }
    }

    // Reading structure->sceneRangeOnSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->sceneRangeOnSettingsExists);
        structure->sceneRangeOnSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->sceneRangeOnSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->sceneRangeOnSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->sceneRangeOnSettings);
        }
    }

    // Reading structure->sceneRangeOffSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->sceneRangeOffSettingsExists);
        structure->sceneRangeOffSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->sceneRangeOffSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->sceneRangeOffSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->sceneRangeOffSettings);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL OISDriverDataClass::Loadmodule_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    OISDriverData::module_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);
    result = result && entry->ReadInt32(&structure->incr_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload OISSlaveInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void OISDriverDataClass::UnloadOISSlaveInfo(
    OISSlaveInfo* structure)
{
    PARAMETER_DELETE[] structure->OISName;
    camxsensorcommonClass::UnloadPowerSequenceInfo(&structure->powerUpSequence);
    camxsensorcommonClass::UnloadPowerSequenceInfo(&structure->powerDownSequence);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload OISDriverData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void OISDriverDataClass::UnloadOISDriverData(
    OISDriverData* structure)
{
    UnloadOISSlaveInfo(&structure->slaveInfo);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->oisinitSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->enableOisSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->disableOisSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->enterDownloadModeSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->movieModeSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->stillModeSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->centeringOnSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->centeringOffSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->pantiltOnSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->sceneOisSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->sceneFilterOnSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->sceneFilterOffSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->sceneRangeOnSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->sceneRangeOffSettings);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Parse symbol table entry, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* OISDriverDataClass::Parse(
    ParameterSetManager* manager,
    ParameterFileSymbolTableEntry* entry) const
{
    OISDriverDataClass* cls = NULL;

    if (PARAMETER_STRCMP(Type, entry->Type) == 0 && Major == entry->Major &&
        Minor == entry->Minor && Patch == entry->Patch)
    {
        cls = PARAMETER_NEW OISDriverDataClass(GetName(entry->Type), 
            entry->ModeId, entry->Mode, entry->SubMode, entry->Group);
        if (cls != NULL)
        {
            BOOL result = TRUE;

            cls->SymbolTableID = entry->ID;
            cls->ID            = entry->ID;

            result = result && LoadOISDriverData(entry, cls);

            if (!result)
            {
                PARAMETER_DELETE cls;
                cls = NULL;
            }
        }
    }
    return (ParameterModule*)cls;
}


CAMX_NAMESPACE_END
